//
//  RansomOrderCell.m
//  LuCaiZhu
//
//  Created by 邓龙 on 2019/4/4.
//

#import "RansomOrderCell.h"
#import "RansomModel.h"
#import "CKPuslichTool.h"
#import "UIColor+NN.h"
#import "Header.h"

@interface RansomOrderCell()<UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet UILabel *name;
@property (weak, nonatomic) IBOutlet UILabel *detailLab;
@property (weak, nonatomic) IBOutlet UILabel *number;

@property (nonatomic, strong) NSArray *detailList;
@property (nonatomic, strong) NSArray *createList;

@end

@implementation RansomOrderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

//赎回单详情
- (void)setRansomOrderDetAction:(RansomOrderDetModel *)model index:(NSInteger)index {
    _detailList = @[@{@"name":@"产品名称", @"value":model.ProductName?model.ProductName:@""},
                    @{@"name":@"赎回开放日", @"value":model.RedeemOpenDay?model.RedeemOpenDay:@""},
                    @{@"name":@"赎回日期", @"value":model.RedeemDate?model.RedeemDate:@""},
                    @{@"name":@"认购金额（万元）", @"value":model.BuyFee?model.BuyFee:@""},
                    @{@"name":@"认购净值", @"value":model.BuyNet?model.BuyNet:@""},
                    @{@"name":@"申请赎回份额", @"value":model.ApplyRedeemShare?model.ApplyRedeemShare:@""},
                    @{@"name":@"赎回净值", @"value":model.RedeemNet?model.RedeemNet:@""},
                    @{@"name":@"实际赎回份额", @"value":model.RedeemShareActually?model.RedeemShareActually:@""},
                    @{@"name":@"实际赎回金额（万元）", @"value":model.RedeemFeeActually?model.RedeemFeeActually:@""},
                    @{@"name":@"赎回状态", @"value":model.RedeemStatus?model.RedeemStatus:@""}];
    
    _name.text = _detailList[index][@"name"];
    _detailLab.text = _detailList[index][@"value"];
}

//新建赎回单显示
- (void)setNewRansomOrderAction:(NewRansomOrderModel *)model index:(NSInteger)index {
    _createList = @[@{@"name": @"产品名称", @"value": model.ProductName?model.ProductName:@""},
                    @{@"name": @"赎回开放日", @"value": model.RedeemOpenDayShow?model.RedeemOpenDayShow:@""},
                    @{@"name": @"赎回截止日", @"value": model.RedeemDue?model.RedeemDue:@""},
                    @{@"name": @"累计认购金额（万元）", @"value": model.TotalAmount?model.TotalAmount:@""},
                    @{@"name": @"累计存续份额", @"value": model.TotalShare?model.TotalShare:@""},
                    @{@"name": @"开放份额", @"value": model.OpenShare?model.OpenShare:@""},
                    @{@"name": @"封闭份额", @"value": model.ClosedShare?model.ClosedShare:@""},
                    @{@"name": @"赎回份额", @"value": model.Redeemshare?model.Redeemshare:@""},
                    @{@"name": @"参考赎回金额（元）", @"value": model.ReferenceAmount?model.ReferenceAmount:@""},
                    @{@"name": @"认购净值", @"value": model.BookingNet?model.BookingNet:@""},
                    @{@"name": @"最新净值", @"value": model.ProductNet?model.ProductNet:@""}];
    _name.text = _createList[index][@"name"];
    if (index == 7) {
        _textField.placeholder = @"请填写赎回份额";
        _textField.text = _createList[index][@"value"];
    }
    else {
        _detailLab.text = _createList[index][@"value"];
    }
}

- (void)textFieldDidEndEditing:(UITextField *)textField {
    _returnBlock(textField.text);
}

//赎回详情信息
- (void)setRansomDetailAction:(NSDictionary *)dic index:(NSInteger)index {
    _detailList = @[@{@"name":@"投资金额", @"value": dic[@"InvestmentAmount"], @"unit": @"万元"},
                    @{@"name":@"投资单位净值", @"value": dic[@"InvestUnitNet"]},
                    @{@"name":@"投资份额", @"value": dic[@"InvestShare"], @"unit": @"份"},
                    @{@"name":@"申请赎回份额", @"value": dic[@"ApplyRedeemShare"], @"unit": @"份"},
                    @{@"name":@"赎回净值", @"value": dic[@"RedeemNet"]},
                    @{@"name":@"实际赎回份额", @"value": dic[@"ActrualRedeemShare"], @"unit": @"份"},
                    @{@"name":@"实际赎回金额", @"value": dic[@"ActrualRedeemAmount"], @"unit": @"万元"},
                    @{@"name":@"该笔赎回收益率", @"value": [NSString stringWithFormat:@"%@", dic[@"ProfitRate"]]}];
    
    _name.text = _detailList[index][@"name"];
    _detailLab.text = _detailList[index][@"value"];
    _number.text = _detailList[index][@"unit"];
}

- (void)setRenGouDetailAction:(NSDictionary *)dic index:(NSInteger)index {
    _detailList = @[@{@"name": @"订单号", @"value": dic[@"BookingNo"]},
                    @{@"name": @"该订单投资金额", @"value": dic[@"InitalAmount"], @"unit": @" 万元"},
                    @{@"name": @"该订单投资单位净值", @"value": dic[@"InitialNet"]},
                    @{@"name": @"该订单投资份额", @"value": dic[@"Initialshare"], @"unit": @" 份"},
                    @{@"name": @"该订单累计赎回份额", @"value": dic[@"Redeemshare"], @"unit": @" 份"},
                    @{@"name": @"该订单累计赎回金额", @"value": dic[@"RedeemAmount"], @"unit": @" 万元"},
                    @{@"name": @"该订单存续份额", @"value": dic[@"SurvivingShare"], @"unit": @" 份"},
                    @{@"name": @"该订单存续资金规模", @"value": dic[@"SubsistAmount"], @"unit": @" 万元"},
                    @{@"name": @"最新单位净值", @"value": dic[@"AssetNet"]},
                    @{@"name": @"该订单收益率", @"value": [NSString stringWithFormat:@"%@", dic[@"ReturnRate"]]},
                    @{@"name": @"上月增幅", @"value": dic[@"LastMonthAdd"]},
                    @{@"name": @"本月增幅（动态）", @"value": dic[@"ThisMonthAdd"]},
                    @{@"name": @"数据截止日期", @"value": 	dic[@"DocDate"]}];
    
    _name.text = _detailList[index][@"name"];
    if (index == 0) {
        _detailLab.textColor = [UIColor colorWithHexString:@"#333333"];
    }
    else {
        _detailLab.textColor = [UIColor colorWithHexString:@"#C83A39"];
    }
    _detailLab.text = _detailList[index][@"value"];
    _number.text = _detailList[index][@"unit"];
}

@end
